package com.aspose.cells;

class zek {
   int a;
   int b;
   CellArea c;
   private zek.za d;

   public zek(CellArea var1, int var2, int var3, zahn var4) {
      this.c = var1;
      this.a = var2;
      this.b = var3;
      this.d = new zek.za(var4);
   }

   public zahn a(zaye var1, zaay var2) {
      return this.d.a(this, var1, var2);
   }

   boolean a() {
      return this.d.a();
   }

   public String toString() {
      return com.aspose.cells.b.a.zr.a(this.c);
   }

   private class za {
      private Object b;
      private int c = 0;
      private int d = 0;
      private byte e = 0;

      za(zahn var2) {
         this.b = var2;
      }

      boolean a() {
         return this.e != 0;
      }

      zahn a(zek var1, zaye var2, zaay var3) {
         if (this.e == 0) {
            if (this.b == null) {
               this.e = 1;
            } else if (this.b instanceof zawk) {
               zawk var4 = (zawk)this.b;
               if (!var4.a()) {
                  var4 = (zawk)var4.b(var3);
               }

               var4.b(true);
               var4.d(5);
               this.a(var4);
            } else if (this.b instanceof zaxa) {
               zaxa var12 = (zaxa)this.b;
               if (!var12.a()) {
                  var12 = (zaxa)var12.b(var3);
               }

               this.a(var12);
            } else {
               this.e = 4;
            }
         }

         int var13;
         zagu[] var15;
         int var16;
         switch(this.e) {
         case 1:
         case 17:
            if (this.b == null) {
               return new zawz(zzk.a, 9, var2.q(), var2.p());
            } else {
               var15 = (zagu[])((zagu[])this.b);
               var13 = this.c + var1.c.StartRow - var2.b();
               var16 = var2.d() - var1.c.StartColumn - this.d;
               if (var3.m != 0) {
                  if (!var2.c() && (var3.m & 1) != 0) {
                     if (var13 + var3.g - var3.l.StartRow >= 0 && var13 + var3.g - var3.l.EndRow < var2.q()) {
                        if (var2.e()) {
                           return this.a(var2, var3, var15, var16, var13, true, false);
                        }

                        if (var16 + var3.l.EndColumn - var3.h + var2.p() >= 1 && var16 + var3.l.StartColumn - var3.h < var15.length) {
                           return new zawj(var15, false, var16, var2.p(), var13, var2.q(), 9, zzk.a, var3.g, var3.h, true, true);
                        }

                        return new zawz(zzk.a, 9, var2.q(), var2.p());
                     }

                     return new zawz(zzk.a, 9, var2.q(), var2.p());
                  }

                  if (!var2.e() && (var3.m & 2) != 0) {
                     if (var13 >= 0 && var13 < var2.q() && var16 + var3.l.EndColumn - var3.h + var2.p() >= 1 && var16 + var3.l.StartColumn - var3.h < var15.length) {
                        if (var2.q() == 1) {
                           return new zawg(var15, false, var16, var2.p(), 9, zzk.a, var3.h, true);
                        }

                        return new zawj(var15, false, var16, var2.p(), var13, var2.q(), 9, zzk.a, var3.g, var3.h, false, true);
                     }

                     return new zawz(zzk.a, 9, var2.q(), var2.p());
                  }
               }

               if (var13 >= 0 && var13 < var2.q()) {
                  return this.a(var2, var3, var15, var16, var13, false, false);
               }

               return new zawz(zzk.a, 9, var2.q(), var2.p());
            }
         case 2:
         case 18:
            if (this.b == null) {
               return new zawz(zzk.a, 9, var2.q(), var2.p());
            } else {
               var15 = (zagu[])((zagu[])this.b);
               var13 = this.d + var1.c.StartColumn - var2.d();
               var16 = var2.b() - var1.c.StartRow - this.c;
               if (var3.m != 0) {
                  if (!var2.e() && (var3.m & 2) != 0) {
                     if (var13 + var3.h - var3.l.StartColumn >= 0 && var13 + var3.h - var3.l.EndColumn < var2.p()) {
                        if (var2.c()) {
                           return this.b(var2, var3, var15, var16, var13, false, true);
                        }

                        if (var16 + var3.l.EndRow - var3.g + var2.q() >= 1 && var16 + var3.l.StartRow - var3.g < var15.length) {
                           return new zawj(var15, true, var16, var2.q(), var13, var2.p(), 9, zzk.a, var3.g, var3.h, true, true);
                        }

                        return new zawz(zzk.a, 9, var2.q(), var2.p());
                     }

                     return new zawz(zzk.a, 9, var2.q(), var2.p());
                  }

                  if (!var2.c() && (var3.m & 1) != 0) {
                     if (var13 >= 0 && var13 < var2.p() && var16 + var3.l.EndRow - var3.g + var2.q() >= 1 && var16 + var3.l.StartRow - var3.g < var15.length) {
                        if (var2.p() == 1) {
                           return new zawg(var15, true, var16, var2.q(), 9, zzk.a, var3.g, true);
                        }

                        return new zawj(var15, true, var16, var2.q(), var13, var2.p(), 9, zzk.a, var3.g, var3.h, true, false);
                     }

                     return new zawz(zzk.a, 9, var2.q(), var2.p());
                  }
               }

               if (var13 >= 0 && var13 < var2.p()) {
                  return this.b(var2, var3, var15, var16, var13, false, false);
               }

               return new zawz(zzk.a, 9, var2.q(), var2.p());
            }
         case 3:
         case 19:
            Object[] var14 = (Object[])((Object[])this.b);
            zagu[][] var5 = (zagu[][])((zagu[][])var14[0]);
            int[] var6 = var14[1] == null ? null : (int[])((int[])var14[1]);
            int var7 = (Integer)var14[2];
            int var8 = var2.b() - var1.c.StartRow - this.c;
            int var9 = var2.d() - var1.c.StartColumn - this.d;
            if (var3.m != 0) {
               if (!var2.c() && (var3.m & 1) != 0) {
                  if (var8 + var3.l.EndRow - var3.g + var2.q() >= 1 && var8 + var3.l.StartRow - var3.g < var5.length) {
                     if (var2.e()) {
                        if (var9 <= -var2.p()) {
                           return new zawz(zzk.a, 9, var2.q(), var2.p());
                        }

                        return new zawi(var5, var8, var9, var6, var2.q(), var2.p(), 9, zzk.a, var3.g, var3.h, true, false, var7);
                     }

                     if (var9 + var3.l.EndColumn - var3.h + var2.p() >= 1 && var9 + var3.l.StartColumn - var3.h < var7) {
                        return new zawi(var5, var8, var9, var6, var2.q(), var2.p(), 9, zzk.a, var3.g, var3.h, true, true, var7);
                     }

                     return new zawz(zzk.a, 9, var2.q(), var2.p());
                  }

                  return new zawz(zzk.a, 9, var2.q(), var2.p());
               }

               if (var8 < 0 || var8 >= var5.length) {
                  return new zawz(zzk.a, 9, var2.q(), var2.p());
               }

               if (!var2.e() && (var3.m & 2) != 0) {
                  if (var2.q() == 1) {
                     zagu[] var10 = var5[var8];
                     if (var10 == null) {
                        return new zawz(zzk.a, 9, var2.q(), var2.p());
                     }

                     int var11 = var6 != null && var8 < var6.length ? var9 - var6[var8] : var9;
                     if (var11 + var3.l.EndColumn - var3.h + var2.p() >= 1 && var11 + var3.l.StartColumn - var3.h < var10.length) {
                        return new zawg(var10, false, var11, var2.p(), 9, zzk.a, var3.h, true);
                     }

                     return new zawz(zzk.a, 9, var2.q(), var2.p());
                  }

                  if (var9 + var3.l.EndColumn - var3.h + var2.p() >= 1 && var9 + var3.l.StartColumn - var3.h < var7) {
                     return new zawi(var5, var8, var9, var6, var2.q(), var2.p(), 9, zzk.a, var3.g, var3.h, false, true, var7);
                  }

                  return new zawz(zzk.a, 9, var2.q(), var2.p());
               }
            }

            if (var2.q() != 1) {
               if (var2.p() == 1) {
                  if (var9 >= 0 && var9 < var7 && var8 < var5.length && var8 + var2.q() >= 1) {
                     return new zawh(var5, var8, var9, var6, var2.q(), 9, zzk.a, var3.g, var3.h, false, false, var7);
                  }

                  return new zawz(zzk.a, 9, var2.q(), 1);
               } else {
                  if (var8 < var5.length && var8 + var2.q() >= 1 && var9 < var7 && var9 + var2.p() >= 1) {
                     return new zawi(var5, var8, var9, var6, var2.q(), var2.p(), 9, zzk.a, var3.g, var3.h, false, false, var7);
                  }

                  return new zawz(zzk.a, 9, var2.q(), var2.p());
               }
            } else {
               if (var8 >= 0 && var8 < var5.length && var5[var8] != null) {
                  return this.a(var2, var3, var5[var8], var6 != null && var8 < var6.length ? var9 - var6[var8] : var9, 0, false, false);
               }

               return new zawz(zzk.a, 9, 1, var2.p());
            }
         case 4:
            return (zahn)this.b;
         case 5:
         case 6:
         case 7:
         case 8:
         case 9:
         case 10:
         case 11:
         case 12:
         case 13:
         case 14:
         case 15:
         case 16:
         default:
            return null;
         }
      }

      private zahn a(zaye var1, zaay var2, zagu[] var3, int var4, int var5, boolean var6, boolean var7) {
         if (var1.p() == 1) {
            return (zahn)(var4 >= 0 && var4 < var3.length && var3[var4] != null ? new zaxh(var3[var4], zzk.a, 9, var1.q(), 1, var5, 0, var2.g, var2.h, var6, var7) : new zawz(zzk.a, 9, var1.q(), 1));
         } else if (var4 < var3.length && var4 + var1.p() >= 1) {
            if (var4 + var1.p() == 1) {
               return new zaxh(var3[0], zzk.a, 9, var1.q(), var1.p(), var5, -var4, var2.g, var2.h, var6, var7);
            } else if (var4 == var3.length - 1) {
               return new zaxh(var3[var4], zzk.a, 9, var1.q(), var1.p(), var5, 0, var2.g, var2.h, var6, var7);
            } else {
               return (zahn)(var1.q() == 1 ? new zawg(var3, false, var4, var1.p(), 9, zzk.a, var2.h, var7) : new zawj(var3, false, var4, var1.p(), var5, var1.q(), 9, zzk.a, var2.g, var2.h, var6, var7));
            }
         } else {
            return new zawz(zzk.a, 9, var1.q(), var1.p());
         }
      }

      private zahn b(zaye var1, zaay var2, zagu[] var3, int var4, int var5, boolean var6, boolean var7) {
         if (var1.q() == 1) {
            return (zahn)(var4 >= 0 && var4 < var3.length && var3[var4] != null ? new zaxh(var3[var4], zzk.a, 9, 1, var1.p(), 0, var5, var2.g, var2.h, var6, var7) : new zawz(zzk.a, 9, 1, var1.p()));
         } else if (var4 < var3.length && var4 + var1.q() >= 1) {
            if (var4 + var1.q() == 1) {
               return new zaxh(var3[0], zzk.a, 9, var1.q(), var1.p(), -var4, var5, var2.g, var2.h, var6, var7);
            } else if (var4 == var3.length - 1) {
               return new zaxh(var3[var4], zzk.a, 9, var1.q(), var1.p(), 0, var5, var2.g, var2.h, var6, var7);
            } else {
               return (zahn)(var1.p() == 1 ? new zawg(var3, true, var4, var1.q(), 9, zzk.a, var2.g, var6) : new zawj(var3, true, var4, var1.q(), var5, var1.p(), 9, zzk.a, var2.g, var2.h, var6, var7));
            }
         } else {
            return new zawz(zzk.a, 9, var1.q(), var1.p());
         }
      }

      private void a(zahn var1) {
         this.b = null;
         int var2 = var1.s();
         if (var2 < 0) {
            this.e = 1;
         } else {
            int var3 = var1.r();
            int var4 = var1.t();
            int var5 = var1.u();
            var1.f();
            zagu var8;
            if (var2 == var3) {
               boolean var6 = true;
               if (var5 == var4) {
                  var1.g();
                  zagu var17 = var1.h();
                  if (var17.b() == 13) {
                     var6 = false;
                  }

                  this.b = new zagu[]{var17};
                  this.c = var3;
                  this.d = var4;
               } else {
                  this.c = var3;
                  this.d = var4;
                  zagu[] var7 = new zagu[var5 - var4 + 1];
                  com.aspose.cells.a.c.zc.a(var7, 0, var7.length, zzk.a);

                  for(this.b = var7; var1.g(); var7[var1.j() - var4] = var8) {
                     var8 = var1.h();
                     if (var6 && var8.b() == 13) {
                        var6 = false;
                     }
                  }
               }

               if (var6) {
                  this.e = 1;
               } else {
                  this.e = 17;
               }
            } else if (var5 == var4) {
               this.c = var3;
               this.d = var4;
               zagu[] var16 = new zagu[var2 - var3 + 1];
               com.aspose.cells.a.c.zc.a(var16, 0, var16.length, zzk.a);
               this.b = var16;

               boolean var19;
               for(var19 = true; var1.g(); var16[var1.i() - var3] = var8) {
                  var8 = var1.h();
                  if (var19 && var8.b() == 13) {
                     var19 = false;
                  }
               }

               if (var19) {
                  this.e = 2;
               } else {
                  this.e = 18;
               }
            } else {
               this.c = var3;
               zagu[][] var18 = new zagu[var2 - var3 + 1][];
               int[] var20 = new int[var18.length];
               var5 -= var4;
               zagu[] var21 = new zagu[var5 + 1];
               com.aspose.cells.a.c.zc.a(var21, 0, var21.length, zzk.a);
               int var9 = -1;
               int var10 = -1;
               boolean var11 = true;
               boolean var12 = true;

               boolean var13;
               zagu var14;
               zagu[] var15;
               for(var13 = true; var1.g(); var21[var9] = var14) {
                  int var22 = var1.i() - var3;
                  if (var22 == var10) {
                     var9 = var1.j() - var4;
                  } else {
                     if (var9 > -1) {
                        if (var20[var10] == 0 && var9 == var5) {
                           var18[var10] = var21;
                           var21 = new zagu[var21.length];
                        } else {
                           var15 = new zagu[var9 - var20[var10] + 1];
                           System.arraycopy(var21, var20[var10], var15, 0, var15.length);
                           var18[var10] = var15;
                        }

                        com.aspose.cells.a.c.zc.a(var21, 0, var21.length, zzk.a);
                        var9 = var1.j() - var4;
                        if (var12 && var9 != var20[var10]) {
                           var12 = false;
                        }
                     } else {
                        var9 = var1.j() - var4;
                     }

                     var10 = var22;
                     var20[var22] = var9;
                  }

                  var14 = var1.h();
                  if (var13 && var14.b() == 13) {
                     var13 = false;
                  }
               }

               if (var13) {
                  this.e = 3;
               } else {
                  this.e = 19;
               }

               if (var20[var10] == 0 && var9 == var5) {
                  var18[var10] = var21;
               } else {
                  var15 = new zagu[var9 - var20[var10] + 1];
                  System.arraycopy(var21, var20[var10], var15, 0, var15.length);
                  var18[var10] = var15;
               }

               if (var12) {
                  this.d = var4 + var20[var10];
                  var20 = null;
               } else {
                  this.d = var4;
               }

               this.b = new Object[]{var18, var20, var5 + var4 + 1};
            }

         }
      }
   }
}
